<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form>
        <span>账号</span>
        <input id="username" type="text">
        <span>密码</span>
        <input id="userpwd" type="text">
        <input type="button" onclick="llogin()">
    </form>
    <script src="/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        //登录
        function llogin() {
            var userName = $("#username").val();
            var password = $("#userpwd").val();
            var serch = {
                "userName":userName,
                "password":password,
                "rememberMe":false
            };
            console.log(userName);
            console.log(password);
            if(userName == "" || password == ""){
                alert("请输入账号密码")
                return;
            }
            $.ajax({
                url: "/api/login",
                type: "post",
                contentType: "application/json",
                data : JSON.stringify(serch),
                dataType : "json",
                success:function (data) {
                    if (data.status == 200) {
                        alert("登录成功")
                        window.location.href = "http://www.baidu.com";
                    } else {
                        alert(data.status)
                    }
                },
                error: function (data) {
                    alert(data.responseText);
                },
            });

        }
    </script>
</body>
</html>